home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cocktail / cg.lha / cg / src / cg.lalr < prev    next >
Text File  |  1992-11-24  |  16KB  |  500 lines

  1. (* Ich, Doktor Josef Grosch, Informatiker, 21.3.1989 *)
  2.  
  3. GLOBAL {
  4.  
  5. FROM StringMem    IMPORT GetString;
  6. FROM Strings    IMPORT tString, SubString, Length, ArrayToString, IntToString, Concatenate;
  7. FROM Idents    IMPORT tIdent, NoIdent, MakeIdent;
  8. FROM Texts    IMPORT MakeText;
  9. FROM Scanner    IMPORT BeginScanner, tScanAttribute, Attribute;
  10. FROM Positions    IMPORT NoPosition;
  11.  
  12. IMPORT Idents;
  13.  
  14. FROM Tree    IMPORT
  15.    iInteger    , Reverse    , MakeTree    , Input        ,
  16.    Output    , Synthesized    , Inherited    , String    ,
  17.    Nonterminal    , Terminal    , Explicit    , HasSelector    ,
  18.    Thread    , Virtual    , Stack        , Demand    ,
  19.    Funct    , Ignore    , Abstract    , nNoAction    ,
  20.    nNoProp    , nNoAttribute    , nNoClass    , nNoDecl    ,
  21.    nNoDesignator, nNoLayout    , nNoModule    , nNoName    ,
  22.    nNoPrec    , NoTree    , tTree        , TreeRoot    , ViewName    ,
  23.    SubUnit    , mAg        , mClass    , mChild    ,
  24.    mAttribute    , mActionPart    , mLeftAssoc    , mRightAssoc    ,
  25.    mNonAssoc    , mAssign    , mCopy        , mTargetCode    ,
  26.    mOrder    , mCheck    , mDesignator    , mIdent    , mRemote    ,
  27.    mAny        , mAnys        , mLayoutAny    , mModule    ,
  28.    mDecl    , mName        , mProp        , mSelect    ,
  29.    ReverseTree    , BeginTree    , Codes        , CloseTree    ;
  30.  
  31. TYPE
  32.    tParsAttribute = RECORD
  33.       CASE : INTEGER OF
  34.       | 1: Scan        : Scanner.tScanAttribute;
  35.            Properties    : BITSET;
  36.       | 2: Tree        : tTree;
  37.        Ident    : tIdent;
  38.       END;
  39.    END;
  40.  
  41. VAR
  42.    Properties, InitProperties    : BITSET;
  43.    String1, String2        : tString;
  44.    ClassCount            : INTEGER;
  45.    i                : CARDINAL;
  46.    ClassIdent, ModuleIdent    : tIdent;
  47.    ParserName, TreeName, EvalName: tIdent;
  48.  
  49. PROCEDURE mCodes (): tTree;
  50.    VAR t: tTree;
  51.    BEGIN
  52.       t := MakeTree (Codes);
  53.       WITH t^.Codes DO
  54.      MakeText (Export);
  55.      MakeText (Import);
  56.      MakeText (Global);
  57.      MakeText (Local);
  58.      MakeText (Begin);
  59.      MakeText (Close);
  60.      ExportLine := NoPosition;
  61.      ImportLine := NoPosition;
  62.      GlobalLine := NoPosition;
  63.      LocalLine  := NoPosition;
  64.      BeginLine  := NoPosition;
  65.      CloseLine  := NoPosition;
  66.       END;
  67.       RETURN t;
  68.    END mCodes;
  69.  
  70. PROCEDURE UpdateName (VAR Name: tIdent; Ident: tIdent);
  71.    BEGIN
  72.       IF Name = NoIdent THEN Name := Ident; END
  73.    END UpdateName;
  74. }
  75.  
  76. BEGIN    {
  77.    BeginScanner;
  78.    ClassCount      := 0;
  79.    InitProperties := {Input};
  80.    ModuleIdent      := NoIdent;
  81.    SubUnit      := NoIdent;
  82.    ViewName      := NoIdent;
  83.    ParserName      := NoIdent;
  84.    TreeName      := NoIdent;
  85.    EvalName      := NoIdent;
  86. }
  87.  
  88. TOKEN
  89.    Ident    = 1
  90.    Integer    = 2
  91.    String    = 3
  92.    TargetCode    = 4
  93.    Code        = 5
  94.    WhiteSpace    = 7
  95.  
  96.    'LEFT'    = 37
  97.    'NONE'    = 39
  98.    'PREC'    = 36
  99.    'RIGHT'    = 38
  100.    'RULE'    = 22
  101.    AFTER    = 24
  102.    BEFORE    = 25
  103.    BEGIN    = 10
  104.    CHECK    = 26
  105.    CLOSE    = 11
  106.    DECLARE    = 12
  107.    DEMAND    = 28
  108.    END        = 13
  109.    EVAL        = 14
  110.    EXPORT    = 15
  111.    FOR        = 71
  112.    FUNCTION    = 6
  113.    GLOBAL    = 16
  114.    IGNORE    = 72
  115.    IMPORT    = 30
  116.    INHERITED    = 34
  117.    INPUT    = 31
  118.    LOCAL    = 18
  119.    MODULE    = 19
  120.    OUTPUT    = 32
  121.    PARSER    = 35
  122.    PROPERTY    = 70
  123.    REMOTE    = 76
  124.    REVERSE    = 21
  125.    SCANNER    = 77
  126.    SELECT    = 74
  127.    STACK    = 20
  128.    SUBUNIT    = 75
  129.    SYNTHESIZED    = 33
  130.    THREAD    = 27
  131.    TREE        = 23
  132.    VIEW        = 78
  133.    VIRTUAL    = 17
  134.  
  135.    '('        = 40
  136.    ')'        = 41
  137.    '['        = 42
  138.    ']'        = 43
  139.    '{'        = 44
  140.    '}'        = 45
  141.    ','        = 46
  142.    ';'        = 47
  143.    '.'        = 48
  144.    ':'        = 49
  145.    '='        = 50
  146.    ':='        = 52
  147.    '<'        = 57
  148.    '>'        = 58
  149.    '->'        = 59
  150.    ':-'        = 60
  151.    '=>'        = 61
  152.    '<-'        = 62
  153.  
  154. RULE
  155.  
  156. Cg    :
  157.       ScannerName ParserCodes TreeCodes EvalCodes PrecPart PropPart DeclPart RulePart Modules
  158.     { TreeRoot := mAg (NoIdent, $1.Ident, ParserName, $2.Tree, TreeName, $3.Tree, EvalName, $4.Tree, $5.Tree, $6.Tree, $7.Tree, $8.Tree, ReverseTree ($9.Tree)); }
  159.     | MODULE Ident
  160.     { ModuleIdent := $0.Scan.Ident; }
  161.       ScannerName ParserCodes TreeCodes EvalCodes PrecPart PropPart DeclPart RulePart END Ident Modules
  162.     { TreeRoot := mAg ($2.Scan.Ident, $4.Ident, ParserName, $5.Tree, TreeName, $6.Tree, EvalName, $7.Tree, $8.Tree, $9.Tree, $10.Tree, $11.Tree, ReverseTree ($14.Tree)); }
  163.     .
  164. ScannerName:
  165.     { $$.Ident := NoIdent; }
  166.     | SCANNER
  167.     { ArrayToString ("Scanner", String1);
  168.       $$.Ident := MakeIdent (String1); }
  169.     | SCANNER Name0
  170.     { $$.Ident := $2.Scan.Ident; }
  171.     .
  172. ParserCodes:
  173.     { $$.Tree := mCodes (); }
  174.     | PARSER       Codes
  175.     { $$.Tree := $2.Tree; }
  176.     | PARSER Name0 Codes
  177.     { $$.Tree := $3.Tree; UpdateName (ParserName, $2.Scan.Ident); }
  178.     .
  179. TreeCodes:         SubUnit
  180.     { $$.Tree := mCodes (); }
  181.     | TREE       SubUnit Codes
  182.     { $$.Tree := $3.Tree; }
  183.     | TREE Name0 SubUnit Codes
  184.     { $$.Tree := $4.Tree; UpdateName (TreeName, $2.Scan.Ident); }
  185.     .
  186. EvalCodes:
  187.     { $$.Tree := mCodes (); }
  188.     | EVAL       Codes
  189.     { $$.Tree := $2.Tree; }
  190.     | EVAL Name0 Codes
  191.     { $$.Tree := $3.Tree; UpdateName (EvalName, $2.Scan.Ident); }
  192.     .
  193. Codes    :
  194.     { $$.Tree := mCodes (); }
  195.     | Codes EXPORT TargetCode
  196.     { $$.Tree := $1.Tree;
  197.       $$.Tree^.Codes.Export        := $3.Scan.Text;
  198.       $$.Tree^.Codes.ExportLine := $3.Scan.Position; }
  199.     | Codes IMPORT TargetCode
  200.     { $$.Tree := $1.Tree;
  201.       $$.Tree^.Codes.Import     := $3.Scan.Text;
  202.       $$.Tree^.Codes.ImportLine := $3.Scan.Position; }
  203.     | Codes GLOBAL TargetCode
  204.     { $$.Tree := $1.Tree;
  205.       $$.Tree^.Codes.Global     := $3.Scan.Text;
  206.       $$.Tree^.Codes.GlobalLine := $3.Scan.Position; }
  207.     | Codes LOCAL  TargetCode
  208.     { $$.Tree := $1.Tree;
  209.       $$.Tree^.Codes.Local      := $3.Scan.Text;
  210.       $$.Tree^.Codes.LocalLine  := $3.Scan.Position; }
  211.     | Codes BEGIN  TargetCode
  212.     { $$.Tree := $1.Tree;
  213.       $$.Tree^.Codes.Begin      := $3.Scan.Text;
  214.       $$.Tree^.Codes.BeginLine  := $3.Scan.Position; }
  215.     | Codes CLOSE  TargetCode
  216.     { $$.Tree := $1.Tree;
  217.       $$.Tree^.Codes.Close      := $3.Scan.Text;
  218.       $$.Tree^.Codes.CloseLine  := $3.Scan.Position; }
  219.     .
  220. SubUnit    :
  221.     | SubUnit SUBUNIT Name0
  222.     { UpdateName (SubUnit, $3.Scan.Ident); }
  223.     | SubUnit VIEW Name0
  224.     { UpdateName (ViewName, $3.Scan.Ident); }
  225.     .
  226. PrecPart:
  227.     { $$.Tree := nNoPrec; }
  228.     | 'PREC' Precs 
  229.     { $$.Tree := ReverseTree ($2.Tree); }
  230.     .
  231. Precs    :
  232.     { $$.Tree := nNoPrec; }
  233.     | Precs 'LEFT'  Names
  234.     { $$.Tree := mLeftAssoc  (ReverseTree ($3.Tree), $1.Tree); }
  235.     | Precs 'RIGHT' Names
  236.     { $$.Tree := mRightAssoc (ReverseTree ($3.Tree), $1.Tree); }
  237.     | Precs 'NONE'  Names
  238.     { $$.Tree := mNonAssoc   (ReverseTree ($3.Tree), $1.Tree); }
  239.     .
  240. PropPart:
  241.       Props 
  242.     { $$.Tree := ReverseTree ($1.Tree); }
  243.     .
  244. Props    :
  245.     { $$.Tree := nNoProp; }
  246.     | Props PROPERTY Properties
  247.     { $$.Tree := mProp ($3.Properties, mName (ModuleIdent, NoPosition, nNoName), $1.Tree);
  248.       InitProperties := {}; }
  249.     | Props PROPERTY Properties FOR Names
  250.     { $$.Tree := mProp ($3.Properties, ReverseTree ($5.Tree), $1.Tree);
  251.       InitProperties := {}; }
  252.     | Props SELECT Names
  253.     { $$.Tree := mSelect (ReverseTree ($3.Tree), $1.Tree);
  254.       InitProperties := {}; }
  255.     .
  256. DeclPart:
  257.     { $$.Tree := nNoDecl; }
  258.     | DECLARE Decls
  259.     { $$.Tree := ReverseTree ($2.Tree); }
  260.     .
  261. Decls    :
  262.     { $$.Tree := nNoDecl; }
  263.     | Decls Names '='
  264.     { Properties := InitProperties; }
  265.       AttrDecls '.'
  266.     { $$.Tree := mDecl (ReverseTree ($2.Tree), ReverseTree ($5.Tree), {Nonterminal, Explicit}, $1.Tree); }
  267.     | Decls Names ':'
  268.     { Properties := InitProperties; }
  269.       AttrDecls '.'
  270.     { $$.Tree := mDecl (ReverseTree ($2.Tree), ReverseTree ($5.Tree), {Terminal, Explicit}, $1.Tree); }
  271.     .
  272. Names    :
  273.     { $$.Tree := nNoName; }
  274.     | Names Name1
  275.     { $$.Tree := mName ($2.Scan.Ident, $2.Scan.Position, $1.Tree); }
  276.     | Names ','
  277.     { $$.Tree := $1.Tree; }
  278.     .
  279. RulePart:
  280.     { $$.Tree := nNoClass; }
  281.     | 'RULE' Types
  282.     { $$.Tree := ReverseTree ($2.Tree); }
  283.     .
  284. Types    :
  285.     { $$.Tree := nNoClass; }
  286.  
  287.     | Types BaseTypes '='
  288.     { Properties := InitProperties; }
  289.       AttrDecls Prec Extensions '.'
  290.     { INC (ClassCount); IntToString (ClassCount, String2); ArrayToString ("yy", String1);
  291.       Concatenate (String1, String2); ClassIdent := MakeIdent (String1);
  292.       $$.Tree := mClass (ClassIdent, {Nonterminal, Explicit}, ReverseTree ($5.Tree),
  293.       $7.Tree, $1.Tree, ClassIdent, $3.Scan.Position, 0, $6.Scan.Ident, $2.Tree); }
  294.  
  295.     | Types Name1 BaseTypes '='
  296.     { Properties := InitProperties; }
  297.       AttrDecls Prec Extensions '.'
  298.     { $$.Tree := mClass ($2.Scan.Ident, {Nonterminal, Explicit} + $2.Properties,
  299.          ReverseTree ($6.Tree), $8.Tree, $1.Tree, $2.Scan.Ident, $2.Scan.Position, 0,
  300.          $7.Scan.Ident, $3.Tree); }
  301.  
  302.     | Types Name1 BaseTypes ':'
  303.     { Properties := InitProperties; }
  304.       TokenCode TypeProperties AttrDecls Prec Extensions '.'
  305.     { $$.Tree := mClass ($2.Scan.Ident, {Terminal, Explicit} + $2.Properties + $7.Properties,
  306.          ReverseTree ($8.Tree), $10.Tree, $1.Tree, $2.Scan.Ident, $2.Scan.Position,
  307.          $6.Scan.Integer, $9.Scan.Ident, $3.Tree); }
  308.  
  309.     | Types Name1 Ident BaseTypes ':'
  310.     { Properties := InitProperties; }
  311.       TokenCode TypeProperties AttrDecls Prec Extensions '.'
  312.     { $$.Tree := mClass ($2.Scan.Ident, {Terminal, Explicit, HasSelector} + $2.Properties + $8.Properties,
  313.          ReverseTree ($9.Tree), $11.Tree, $1.Tree, $3.Scan.Ident, $2.Scan.Position,
  314.          $7.Scan.Integer, $10.Scan.Ident, $4.Tree); }
  315.  
  316.     | Types Name1 BaseTypes ':='
  317.     { Properties := InitProperties; }
  318.       AttrDecls Prec Extensions '.'
  319.     { $$.Tree := mClass ($2.Scan.Ident, {Abstract, Explicit} + $2.Properties,
  320.          ReverseTree ($6.Tree), $8.Tree, $1.Tree, $2.Scan.Ident, $2.Scan.Position, 0,
  321.          $7.Scan.Ident, $3.Tree); }
  322.     .
  323. BaseTypes:
  324.     { $$.Tree := nNoName; }
  325.     | '<-' Names
  326.     { $$.Tree := ReverseTree ($2.Tree); }
  327.     .
  328. TokenCode:
  329.     { $$.Scan.Integer := 0; }
  330.     | Integer
  331.     { $$.Scan.Integer := $1.Scan.Integer; }
  332.     .
  333. Prec    :
  334.     { $$.Scan.Ident := NoIdent; }
  335.     | 'PREC' Name1
  336.     { $$.Scan.Ident := $2.Scan.Ident; }
  337.     .
  338. Extensions:
  339.     { $$.Tree := nNoClass; }
  340.     | '<' Types '>'
  341.     { $$.Tree := ReverseTree ($2.Tree); }
  342.     .
  343. AttrDecls:
  344.     { $$.Tree := nNoAttribute; }
  345.     | AttrDecls '->'
  346.     { $$.Tree := $1.Tree; Properties := {}; }
  347.     | AttrDecls '[' Name1           Properties ']'
  348.     { IF Thread IN $4.Properties THEN
  349.          Idents.GetString ($3.Scan.Ident, String1);
  350.          ArrayToString ("In", String2);
  351.          Concatenate (String1, String2);
  352.          $$.Tree := mAttribute ($1.Tree, MakeIdent (String1), iInteger, Properties + $4.Properties + {Inherited}, $3.Scan.Position);
  353.          Idents.GetString ($3.Scan.Ident, String1);
  354.          ArrayToString ("Out", String2);
  355.          Concatenate (String1, String2);
  356.          $$.Tree := mAttribute ($$.Tree, MakeIdent (String1), iInteger, Properties + $4.Properties + {Synthesized}, $3.Scan.Position);
  357.       ELSE
  358.          $$.Tree := mAttribute ($1.Tree, $3.Scan.Ident, iInteger, Properties + $4.Properties, $3.Scan.Position);
  359.       END;
  360.     }
  361.     | AttrDecls '[' Name1 ':' Name1 Properties ']'
  362.     { IF Thread IN $6.Properties THEN
  363.          Idents.GetString ($3.Scan.Ident, String1);
  364.          ArrayToString ("In", String2);
  365.          Concatenate (String1, String2);
  366.          $$.Tree := mAttribute ($1.Tree, MakeIdent (String1), $5.Scan.Ident, Properties + $6.Properties + {Inherited}, $3.Scan.Position);
  367.          Idents.GetString ($3.Scan.Ident, String1);
  368.          ArrayToString ("Out", String2);
  369.          Concatenate (String1, String2);
  370.          $$.Tree := mAttribute ($$.Tree, MakeIdent (String1), $5.Scan.Ident, Properties + $6.Properties + {Synthesized}, $3.Scan.Position);
  371.       ELSE
  372.          $$.Tree := mAttribute ($1.Tree, $3.Scan.Ident, $5.Scan.Ident, Properties + $6.Properties, $3.Scan.Position);
  373.       END;
  374.     }
  375.     | AttrDecls '('           Name1 Properties ')'
  376.     { $$.Tree := mChild ($1.Tree, $3.Scan.Ident, $3.Scan.Ident, Properties + $4.Properties, $3.Scan.Position); }
  377.     | AttrDecls '(' Name1 ':' Name1 Properties ')'
  378.     { $$.Tree := mChild ($1.Tree, $3.Scan.Ident, $5.Scan.Ident, Properties + $6.Properties, $3.Scan.Position); }
  379.     | AttrDecls               Name1 Properties
  380.     { $$.Tree := mChild ($1.Tree, $2.Scan.Ident, $2.Scan.Ident, Properties + $3.Properties, $2.Scan.Position); }
  381.     | AttrDecls     Name1 ':' Name1 Properties
  382.     { $$.Tree := mChild ($1.Tree, $2.Scan.Ident, $4.Scan.Ident, Properties + $5.Properties, $2.Scan.Position); }
  383.     | AttrDecls     '{' Actions '}'
  384.     { $$.Tree := mActionPart ($1.Tree, ReverseTree ($3.Tree)); }
  385.     .
  386. TypeProperties:
  387.     { $$.Properties := {}; }
  388.     .
  389. Properties:
  390.     { $$.Properties := {}; }
  391.     | Properties REVERSE
  392.     { $$.Properties := $1.Properties + {Reverse    }; }
  393.     | Properties INPUT
  394.     { $$.Properties := $1.Properties + {Input    }; }
  395.     | Properties OUTPUT
  396.     { $$.Properties := $1.Properties + {Output    }; }
  397.     | Properties SYNTHESIZED
  398.     { $$.Properties := $1.Properties + {Synthesized    }; }
  399.     | Properties INHERITED
  400.     { $$.Properties := $1.Properties + {Inherited    }; }
  401.     | Properties THREAD
  402.     { $$.Properties := $1.Properties + {Thread    }; }
  403.     | Properties VIRTUAL
  404.     { $$.Properties := $1.Properties + {Virtual    }; }
  405.     | Properties STACK
  406.     { $$.Properties := $1.Properties + {Stack    }; }
  407.     | Properties DEMAND
  408.     { $$.Properties := $1.Properties + {Demand    }; }
  409.     | Properties FUNCTION
  410.     { $$.Properties := $1.Properties + {Funct    }; }
  411.     | Properties IGNORE
  412.     { $$.Properties := $1.Properties + {Ignore    }; }
  413.     .
  414. Actions    :
  415.     { $$.Tree := nNoAction; }
  416.     | Actions Exprs ':=' Exprs ';'
  417.     { $$.Tree := mAssign ($1.Tree, $3.Scan.Position, ReverseTree ($2.Tree), ReverseTree ($4.Tree)); }
  418.     | Actions Exprs ':-' Exprs ';'
  419.     { $$.Tree := mCopy ($1.Tree, $3.Scan.Position, ReverseTree ($2.Tree), ReverseTree ($4.Tree)); }
  420.     | Actions Exprs ':=' Exprs '{' Exprs '}' Exprs ';'
  421.     { $$.Tree := mTargetCode ($1.Tree, $3.Scan.Position, ReverseTree ($2.Tree), ReverseTree ($6.Tree)); }
  422.     | Actions Exprs AFTER Exprs ';'
  423.     { $$.Tree := mOrder ($1.Tree, NoPosition, ReverseTree ($2.Tree), ReverseTree ($4.Tree)); }
  424.     | Actions Exprs BEFORE Exprs ';'
  425.     { $$.Tree := mOrder ($1.Tree, NoPosition, ReverseTree ($4.Tree), ReverseTree ($2.Tree)); }
  426.     | Actions Checks ';'
  427.     { $$.Tree := $2.Tree; $$.Tree^.Check.Next := $1.Tree; }
  428.     | Actions Exprs ';'
  429.     { $$.Tree := mTargetCode ($1.Tree, Attribute.Position, nNoDesignator, ReverseTree ($2.Tree)); }
  430.     | Actions Exprs
  431.     { $$.Tree := mTargetCode ($1.Tree, Attribute.Position, nNoDesignator, ReverseTree ($2.Tree)); }
  432.     .
  433. Checks    : Check
  434.     { $$.Tree := $1.Tree; }
  435.     | Check Checks
  436.     { $$.Tree := $1.Tree; $$.Tree^.Check.Actions := $2.Tree; }
  437.     .
  438. Check    :
  439.                  '=>' Exprs
  440.     { $$.Tree := mCheck (nNoAction, NoPosition, NoTree, ReverseTree ($2.Tree), nNoAction); }
  441.     |            '=>' Exprs '{' Exprs '}' Space
  442.     { $$.Tree := mCheck (nNoAction, NoPosition, NoTree, ReverseTree ($4.Tree), nNoAction); }
  443.     | CHECK Exprs
  444.     { $$.Tree := mCheck (nNoAction, $1.Scan.Position, ReverseTree ($2.Tree), NoTree, nNoAction); }
  445.     | CHECK Exprs '=>' Exprs
  446.     { $$.Tree := mCheck (nNoAction, $1.Scan.Position, ReverseTree ($2.Tree), ReverseTree ($4.Tree), nNoAction); }
  447.     | CHECK Exprs '=>' Exprs '{' Exprs '}' Space
  448.     { $$.Tree := mCheck (nNoAction, $1.Scan.Position, ReverseTree ($2.Tree), ReverseTree ($6.Tree), nNoAction); }
  449.     .
  450. Exprs    :
  451.     { $$.Tree := nNoDesignator; }
  452.     | Exprs Name1 Space ':' Space Ident
  453.     { $$.Tree := mDesignator ($2.Scan.Ident, $6.Scan.Ident, $2.Scan.Position, $1.Tree); }
  454.     | Exprs Name1 Space ':' Space
  455.     { $$.Tree := mIdent ($2.Scan.Ident, $2.Scan.Position, $1.Tree);
  456.       $$.Tree := mAnys (ReverseTree ($3.Tree), $$.Tree);
  457.       $$.Tree := mAny ($4.Scan.StringRef, $$.Tree);
  458.       $$.Tree := mAnys (ReverseTree ($5.Tree), $$.Tree); }
  459.     | Exprs Name1 Space
  460.     { $$.Tree := mIdent ($2.Scan.Ident, $2.Scan.Position, $1.Tree);
  461.       $$.Tree := mAnys (ReverseTree ($3.Tree), $$.Tree); }
  462.     | Exprs ':'
  463.     { $$.Tree := mAny ($2.Scan.StringRef, $1.Tree); }
  464.     | Exprs REMOTE Exprs '=>' Space Ident Space ':' Space Ident
  465.     { $$.Tree := mRemote (ReverseTree ($3.Tree), $6.Scan.Ident, $10.Scan.Ident, $10.Scan.Position, $1.Tree); }
  466.     | Exprs Code
  467.     { $$.Tree := mAny ($2.Scan.StringRef, $1.Tree); }
  468.     | Exprs WhiteSpace
  469.     { $$.Tree := mAny ($2.Scan.StringRef, $1.Tree); }
  470.     .
  471. Modules    :
  472.     { $$.Tree := nNoModule; }
  473.     | Modules MODULE Ident
  474.     { ModuleIdent := $0.Scan.Ident; }
  475.       ParserCodes TreeCodes EvalCodes PropPart DeclPart RulePart END Ident
  476.     { $$.Tree := mModule ($3.Scan.Ident, $5.Tree, $6.Tree, $7.Tree, $8.Tree, $9.Tree, $10.Tree, $1.Tree); }
  477.     .
  478. Name0    :
  479.       Ident
  480.     { $$.Scan := $1.Scan; }
  481.     | String
  482.     { $$.Scan := $1.Scan; GetString ($1.Scan.StringRef, String1);
  483.       SubString (String1, 2, Length (String1) - 1, String2);
  484.       $$.Scan.Ident := MakeIdent (String2); }
  485.     .
  486. Name1    :
  487.       Ident
  488.     { $$.Scan := $1.Scan;
  489.       $$.Properties := {}; }
  490.     | String
  491.     { $$.Scan := $1.Scan; GetString ($1.Scan.StringRef, String1);
  492.       $$.Scan.Ident := MakeIdent (String1);
  493.       $$.Properties := {String}; }
  494.     .
  495. Space    :
  496.     { $$.Tree := nNoLayout; }
  497.     | Space WhiteSpace
  498.     { $$.Tree := mLayoutAny ($2.Scan.StringRef, $1.Tree); }
  499.     .
  500.